package com.feng.util;

import sun.misc.BASE64Encoder;

import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * 加密工具类
 * @author: 丰
 * @date: 2022/12/8 16:50
 */
public final class CodeEncryptUtil {
    private CodeEncryptUtil() {
    }

    public static String md5(String str){
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
            BASE64Encoder encoder = new BASE64Encoder();
            return encoder.encode(md5.digest(str.getBytes(StandardCharsets.UTF_8)));
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        // 123456
        return "4QrcOUm6Wau+VuBX8g+IPg==";
    }

}
